package com.qida.clm.core.utils;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * Created by edgar on 2015/11/14.
 */
public final class ViewUtils {

    private ViewUtils(){}

    public static void setImage(ImageView imageView,int resId){
        imageView.setImageResource(resId);
    }

    public static void setImage(ImageView imageView,Drawable drawable){
        imageView.setImageDrawable(drawable);
    }

    public static void setText(TextView textView,int resId){
        textView.setText(resId);
    }

    public static void setText(TextView textView,CharSequence charSequence){
        textView.setText(charSequence);
    }

    public static void setTextColor(TextView textView,int color){
        textView.setTextColor(color);
    }

    public static void setTextSize(TextView textView,int size){
        textView.setTextSize(size);
    }

    public static void setBackground(View view,Context context,int resId){
        setBackground(view, context.getResources().getDrawable(resId));
    }

    public static void setBackground(View view,Drawable drawable){
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN){
            view.setBackground(drawable);
        } else {
            view.setBackgroundDrawable(drawable);
        }
    }

    public static void setLayoutParams(View view,int width,int height){
        view.setLayoutParams(new ViewGroup.LayoutParams(width,height));
    }
}